<template>
    <view>
        <custom><template #backText>每日任务 / 信用分</template></custom>
        <view class="bg-gradual-nddyny padding-top-40 padding-bottom-60 flex flex-direction align-center">
            <view class="text-xsl text-bold">{{$store.state.user.user_asset_info.credit_score | floor}}</view>
            <view class="text-sm text-bold">
                <text>本月累计 {{pageResult.credit_score_month_get | floor}}</text>
                <text class="margin-left-30">本日累计 {{pageResult.credit_score_today_get | floor}}</text>
            </view>
        </view>
        <nBar title="每日任务"></nBar>
        <view class="cu-list menu sm-border">
            <nMenuItemContentAction>
                <template #content>
                    <text class="text-nddyny">+{{pageResult.daily_task.pay_seller_item_by_user.credit_score}}</text>
                    <text class="margin-left-10">在商家消费 / 累计消费余额</text>
                </template>
                <template #action>
                    {{pageResult.daily_task.pay_seller_item_by_user.complete_times}}
                    /
                    {{pageResult.daily_task.pay_seller_item_by_user.total_times}}
                </template>
            </nMenuItemContentAction>
            <nMenuItemContentAction v-if="$store.state.user.is_seller_firm">
                <template #content>
                    <text class="text-nddyny">+{{pageResult.daily_task.pay_seller_item_by_seller.credit_score}}</text>
                    <text class="margin-left-10">商家收款</text>
                </template>
                <template #action>
                    {{pageResult.daily_task.pay_seller_item_by_seller.complete_times}}
                    /
                    {{pageResult.daily_task.pay_seller_item_by_seller.total_times}}
                </template>
            </nMenuItemContentAction>
        </view>
        <nBar title="每月任务"></nBar>
        <view class="cu-list menu sm-border">
            <nMenuItemContentAction>
                <template #content>
                    <text class="text-nddyny">+{{pageResult.monthly_task.promote_user.credit_score}}</text>
                    <text class="margin-left-10">推广消费股东</text>
                </template>
                <template #action>
                    {{pageResult.monthly_task.promote_user.complete_times}}
                    /
                    {{pageResult.monthly_task.promote_user.total_times}}
                </template>
            </nMenuItemContentAction>
            <nMenuItemContentAction>
                <template #content>
                    <text class="text-nddyny">+{{pageResult.monthly_task.promote_seller.credit_score}}</text>
                    <text class="margin-left-10">推广实体商家</text>
                </template>
                <template #action>
                    {{pageResult.monthly_task.promote_seller.complete_times}}
                    /
                    {{pageResult.monthly_task.promote_seller.total_times}}
                </template>
            </nMenuItemContentAction>
        </view>
        <nBar title="任务要求"></nBar>
        <nDesc class="bg-white">
            <template #bottom>
                1. 推广消费股东任务，消费股东需完成1笔现金10元以上消费。<br>
                2. 推广实体商家任务，商家需完成2笔现金100元以上收款。
            </template>
        </nDesc>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                pageResult: {
                    credit_score_month_get: 0,
                    credit_score_today_get: 0,
                    daily_task: {
                        pay_seller_item_by_user: {
                            is_seller: 0,
                            complete_times: 0,
                            total_times: 0,
                            credit_score: 0,
                        },
                        pay_seller_item_by_seller: {
                            is_seller: 1,
                            complete_times: 0,
                            total_times: 0,
                            credit_score: 0,
                        }
                    },
                    monthly_task: {
                        promote_user: {
                            is_seller: null,
                            complete_times: 0,
                            total_times: 0,
                            credit_score: 0,
                        },
                        promote_seller: {
                            is_seller: null,
                            complete_times: 0,
                            total_times: 0,
                            credit_score: 0,
                        }
                    }
                }
            }
        },
        onLoad() {
            this.$api.post(this, {
                url: '/user/creditScore/page',
                success: (Result) => {
                    if (this.$api.form.toast(this, Result)) return;
                    this.pageResult = Result.result;
                }
            });
        },
        methods: {

        }
    }
</script>
